package com.jueming.cashbook.business.service.impl;

import com.jueming.cashbook.business.mapper.UserMapper;
import com.jueming.cashbook.business.service.UserService;
import com.jueming.cashbook.entity.SysUser;
import com.jueming.cashbook.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<SysUser> getUserList() {
        List<SysUser> userList = userMapper.selectUserList();
        for (int i = 0; i < userList.size(); i++) {
            Date updateTime = userList.get(i).getUpdateTime();
            userList.get(i).setUpdateTimeStr(DateUtil.DateToString(updateTime));
        }
        return userList;
    }

    @Override
    public SysUser getUserByName(SysUser sysUser) {
        return userMapper.selectUserByName(sysUser);
    }

}
